package com.jxnu.nav_search.database;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.widget.Toast;

public class SuggestionsSQLiteOpenHelperUtils {

    private Context mContext;
    private SuggestionsSQLiteOpenHelper sqLiteOpenHelper;
    private SQLiteDatabase db;

    public SuggestionsSQLiteOpenHelperUtils(Context mContext) {
        this.mContext = mContext;
    }

    //创建数据库
    public void createDB() {
        sqLiteOpenHelper = new SuggestionsSQLiteOpenHelper(mContext);
        db = sqLiteOpenHelper.getWritableDatabase();
        Toast.makeText(mContext, "database created!", Toast.LENGTH_SHORT);
        System.out.println("database created! ------------------------------------------------");
    }

    public void insert(ContentValues cv) {
        db.insert(SuggestionsSQLiteOpenHelper.TABLE_NAME, null, cv);
    }

    public Cursor selectAll() {
        return db.rawQuery("select * from person", null);
    }
}
